
#include "Sensor.h"
#include "Sensor_HotSwap.h"
#include "MMC_Appi.h"


uint8 HowSwapSensor_Scan(Sensor* pSensor)
{
	static const uint8 MAX_SCAN_COUNT = 3;
	uint8 state;
	static uint8 count = 0;
	
	if(Is_HandSwitch_Close())
	{
		state = HANDLE_CLOSED;
	}
	else
	{
		state = HANDLE_OPENED;
	}

	if(state != pSensor->m_RawValue)
	{
		if(count++ >= MAX_SCAN_COUNT)
		{
			count = 0;
			return state;
		}
		else
		{
			return pSensor->m_RawValue;
		}
	}
	else
	{
		count = 0;
	}

	return state;
}
